package JavaSE.d4;
import java.math.BigInteger;

//	测试计算1～50的阶乘的和所耗费的毫秒级时间
public class Test28 {
    public static void main(String[] args) {
        long l = System.currentTimeMillis();
        BigInteger a=new BigInteger("0");
        for (int i = 1; i <=50 ; i++) {
            a=a.add(getNfactorial(i));
        }


        long l1 = System.currentTimeMillis();
        System.out.println("执行时间："+(l1-l)+"毫秒，50个阶乘的和"+a);
    }
    public static BigInteger getNfactorial(int num){
        String num1=num+"";
        if(num1.equals("1")){
            return new BigInteger("1");
        }
        return  new BigInteger(num1).multiply(getNfactorial(num-1));
    }

}